<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css"/>
    <title>房屋租赁网</title>
    <link rel="stylesheet" href="/static/css/global.css">
    <script src="/static/layui/layui.js"></script>
</head>
<body>
<div class="layui-carousel" id="bg-item">
    <div class="layui-header title">
        <div class="layui-container">
            <div class="layui-logo layui-pull-left">
                <img src="/static/img/logo.png" width="240px">
            </div>
            <c:if test="${not empty loginUser }">
                <div class="personalCenter layui-pull-right"><a th:href="@{/rent/user/toUserIndex}" target="_blank" style="color:#fff"><i class="layui-icon layui-icon-tree"></i>个人中心</a></div>
            </c:if>


        </div>
    </div>
            <div class="layui-container">
                <div class="seach-input">
                    <form class="seach-form layui-form" method="post" th:action="@{/rent/house/findHouse}">
                        <div class="layui-pull-left input">
                            <input type="text" placeholder="请输入房屋所在地" name="keywords" class="seach layui-input"  lay-verify="">
                        </div>
                        <div class="layui-pull-left button">
                            <button class="btn seach-btn" lay-submit><i class="layui-icon layui-icon-search" style="font-size: 24px;"></i></button>
                        </div>
                    </form>
                </div>
            </div>
    <div carousel-item>
        <div style="background: url('../../static/img/banner1.jpg')no-repeat center/cover"></div>
        <div style="background: url('../../static/img/banner2.jpg')no-repeat center/cover"></div>
        <div style="background: url('../../static/img/banner3.jpg')no-repeat center/cover"></div>
        <div style="background: url('../../static/img/banner4.jpg')no-repeat center/cover"></div>
    </div>
</div>
        <div class="layui-container">
            <div class="layui-tab layui-tab-brief" id="sign" lay-filter="" style="display: none;">
                <ul class="layui-tab-title">
                    <li class="layui-this">登录</li>
                    <li>注册</li>
                </ul>
                <div class="layui-tab-content">
                    <div class="layui-tab-item layui-show">
                        <div class="" style="margin: 40px 20px;">

                        </div>
                    </div>
                    <div class="layui-tab-item">
                        <div class="" style="margin: 30px 20px;">

                        </div>
                    </div>
                </div>
            </div>
        </div>
<!--内容开始-->
<div class="list_control_bar layui-container" style="padding: 0">
    <div>
        <div class="list_title layui-pull-left"><span>全部房源</span></div>
        <div class="list_more">
            <ul class="layui-pull-right list-item">
                <li class="click-this"><a th:href="@{/rent/house/allHouse}">默认排序</a></li>
                <li class="click-this"><a th:href="@{/rent/house/houseAsc}">价格升序</a></li>
                <li class="click-this"><a th:href="@{/rent/house/houseDesc}">价格降序</a></li>
            </ul>
        </div>
    </div>
</div>

<section class="layui-container">
<!--    <hr>-->
<!--&lt;!&ndash;    <h2>目前有<span style="color: #ffc601;margin: 0 5px;">[[${size}]]</span>套房源</h2>&ndash;&gt;-->
<!--    <hr>-->
    <div class="house-detail">
        <ul>
        	<div th:each="h:${houses}" >
	            <li>
	                <a th:href="@{/rent/house/seeHouse/{houseId}(houseId=${h.getHouseId()})}" class="show-image">
	                    <img th:src="@{${h.getHouseImage()}}" width="240px" height="180px">

	                </a>
	                <div class="show-details">
	                    <p class="house-title">
	                        <a th:href="@{/rent/house/seeHouse/{houseId}(houseId=${h.getHouseId()})}" th:value="${h.getHouseDesc()}"></a>
	                    </p>
	                    <p class="house-about">
	                        <span class="layui-icon layui-icon-home"></span>
	                        <span>[[${h.getHouseType()}]]</span>
	                        <span class="flag-line">|</span>
	                        <span>[[${h.getHouseArea()}]] m<sup>2</sup></span>
	                        <span class="flag-line">|</span>
	                        <span>联系号码: [[${h.getHouseTel()}]]</span>
	                        <span class="flag-line">|</span>
	                    </p>
	                    <p class="house-address clearfix">
	                        <span class="layui-icon layui-icon-location"></span>
	                        <span class="whole-line">
			    		        <span>[[${h.getHouseAddress()}]]</span>
					        </span>
	                    </p>
	                    <div class="show-price">
	                        <span class="sale-price">[[${h.getHousePrice()}]]</span>
	                        <span class="sale-unit">元/月</span>
	                    </div>
                        <p class="house-address clearfix" style="color: #28ff73">
                            <span class="layui-icon"></span>
                            <span class="whole-line" style="color: #009E94">
			    		        <span>[[${h.getHouseDesc()}]]</span>
					        </span>
                        </p>
	                </div>
	            </li>
        	</div>
        </ul>
    </div>
</section>
<footer>

</footer>
        <script>
            layui.use(['element', 'carousel','layer','form'], function () {
                var element = layui.element,
                    carousel = layui.carousel,
                    $ = layui.jquery,
                    layer = layui.layer,
                    form = layui.form;

                var layer_index;
                carousel.render({
                    elem:"#bg-item",
                    width:"100%",
                    height:"600px",
                    anim:"fade"
                });
                $('.operation').click(function () {
                    layer_index = layer.open({
                        type:1,
                        content:$('#sign'),
                        area:['360px','460px'],
                        title:"房屋租赁",
                        closeBtn:2
                    });
                });
                $('.list-item li').click(function () {
                    $('.list-item li').removeClass('click-this');
                    $(this).addClass('click-this');
                });

                $('.regist-btn').click(function () {
                    if($("input[name='uName']").val()!=""&&$("input[name='uPassword']").val()!=""&&$("input[name='uPhoneNumber']").val()!=""&&$("input[name='uNickName']").val()!=""){
                        $.post("regist",$('.form').serialize(),function (res) {
                            console.log(res)
                            if(res==='OK'){
                                layer.close(layer_index);
                                layer.alert("注册成功",{icon:1,time:2000});
                                $('.form')[0].reset();
                            }else{
                                layer.msg("注册失败,用户名以存在");
                            }
                        })
                    }else{
                        layer.msg("请填写所有表单");
                    }
                });

                form.on("submit(login)",function(){
                    $.post("login",$('#login').serialize(),function (res) {
                        if(res==="OK"){
                            // window.location.href="toIndexPage";
                            window.location.href="toIndexPage";
                        }else{
                            layer.msg("用户名或者密码错误");
                        }
                    });
                    return false;
                });
            });
        </script>
</body>
</html>
